﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
using MicroLink.StsDev2008AddIn.DeploymentFiles;

namespace MicroLink.StsDev2008AddIn.BuildTasks
{
    
    public class RefreshSolutionFiles : Task
    {
        #region ProjectDirectory
        [Required()]
        public string ProjectDirectory
        {
            get;
            set;
        }
        #endregion

        #region TargetName
        [Required()]
        public string TargetName
        {
            get;
            set;
        }
        #endregion

        #region BuildDirectory
        [Required()]
        public string BuildDirectory
        {
            get;
            set;
        }
        #endregion

        #region ProjectFile
        public string ProjectFile
        {
            get;
            set;
        }
        #endregion

        public override bool Execute()
        {
            FeatureBuilder.Update(ProjectDirectory, BuildDirectory, TargetName);
            if (string.IsNullOrEmpty(ProjectFile))
                ManifestXmlBuilder.Create(ProjectDirectory, BuildDirectory, TargetName);
            else
                ManifestXmlBuilder.Create(ProjectDirectory, BuildDirectory, TargetName, ProjectFile);

            CabDdfBuilder.Create(
                ProjectDirectory, 
                BuildDirectory, 
                TargetName);
            return true;
        }
    }
}
